package com.ruyuan.process.engine;

import com.ruyuan.process.engine.config.ProcessParser;
import com.ruyuan.process.engine.model.ProcessContextFactory;
import com.ruyuan.process.engine.process.ProcessContext;
import lombok.extern.slf4j.Slf4j;

/**
 * 流程引擎启动器
 *
 * 儒猿课堂: http://www.ruyuan2020.com
 * @Author zhonghuashishan
 * @Remark 有问题直接联系客服VX: ruyuan-1111 ，源码-笔记-技术交流群
 * @Version 1.0
 **/
@Slf4j
public class ProcessEngine {

    private final ProcessContextFactory factory;

    public ProcessEngine(ProcessParser processParser) throws Exception {
        this.factory = new ProcessContextFactory(processParser.parse());
    }

    /**
     * 获取一个流程上下文
     *
     * @param name 流程名称
     * @return 流程上下文
     */
    public ProcessContext getContext(String name) {
        return factory.getContext(name);
    }
}
